﻿@model OrderModel
@using Nop.Core.Domain.Tax;
@using Nop.Core.Domain.Orders;

@if (!Model.IsLoggedInAsVendor)
{
    <script type="text/javascript">
        $(document).ready(function() {
            toggleChangeOrderStatus(false);
            toggleOrderTotals(false);
            toggleCC(false);
        });

        function toggleChangeOrderStatus(editmode) {
            if (editmode) {
                $('#pnlChangeOrderStatus').show();
                $('#btnChangeOrderStatus').hide();
            } else {
                $('#pnlChangeOrderStatus').hide();
                $('#btnChangeOrderStatus').show();
            }
        }

        function toggleOrderTotals(editmode) {
            if (editmode) {
                $('#trEditOrderTotals').show();
                $('#btnEditOrderTotals').hide();
                $('#btnSaveOrderTotals').show();
                $('#btnCancelOrderTotals').show();
            } else {
                $('#trEditOrderTotals').hide();
                $('#btnEditOrderTotals').show();
                $('#btnSaveOrderTotals').hide();
                $('#btnCancelOrderTotals').hide();
            }
        }

        function toggleCC(editmode) {
            if (editmode) {
                $('#lblCardType').hide();
                $('#@Html.FieldIdFor(model => model.CardType)').show();
                $('#lblCardName').hide();
                $('#@Html.FieldIdFor(model => model.CardName)').show();
                $('#lblCardNumber').hide();
                $('#@Html.FieldIdFor(model => model.CardNumber)').show();
                         $('#lblCardCvv2').hide();
                         $('#@Html.FieldIdFor(model => model.CardCvv2)').show();
                         $('#lblCardExpirationMonth').hide();
                         $('#@Html.FieldIdFor(model => model.CardExpirationMonth)').show();
                         $('#lblCardExpirationYear').hide();
                         $('#@Html.FieldIdFor(model => model.CardExpirationYear)').show();
                         $('#btnEditCC').hide();
                         $('#btnSaveCC').show();
                         $('#btnCancelCC').show();
                     } else {
                         $('#lblCardType').show();
                         $('#@Html.FieldIdFor(model => model.CardType)').hide();
                         $('#lblCardName').show();
                         $('#@Html.FieldIdFor(model => model.CardName)').hide();
                         $('#lblCardNumber').show();
                         $('#@Html.FieldIdFor(model => model.CardNumber)').hide();
                         $('#lblCardCvv2').show();
                         $('#@Html.FieldIdFor(model => model.CardCvv2)').hide();
                         $('#lblCardExpirationMonth').show();
                         $('#@Html.FieldIdFor(model => model.CardExpirationMonth)').hide();
                         $('#lblCardExpirationYear').show();
                         $('#@Html.FieldIdFor(model => model.CardExpirationYear)').hide();
                         $('#btnEditCC').show();
                         $('#btnSaveCC').hide();
                         $('#btnCancelCC').hide();
                     }
                 }

    </script>
}
<table class="adminContent">
    @if (!Model.IsLoggedInAsVendor)
    {
        <tr>
            <td class="adminTitle">
                <strong>
                    @Html.NopLabelFor(model => model.OrderStatus): </strong>
            </td>
            <td class="adminData">
                <strong>
                    @Model.OrderStatus</strong>&nbsp;
                @if (Model.CanCancelOrder)
                {
                    <input type="submit" name="cancelorder" value="@T("Admin.Orders.Fields.OrderStatus.Cancel")" id="cancelorder" class="adminButton" onclick="return confirm('@T("Admin.Common.AreYouSure")');"  />
                }
                <input type="submit" name="btnChangeOrderStatus" value="@T("Admin.Orders.Fields.OrderStatus.Change")" onclick="toggleChangeOrderStatus(true);return false;" id="btnChangeOrderStatus" class="adminButton"  />
                <div id="pnlChangeOrderStatus">
                    <em>@T("Admin.Orders.Fields.OrderStatus.Change.ForAdvancedUsers")</em>
                    <br />
                    @Html.DropDownListFor(model => model.OrderStatusId, ((OrderStatus)Model.OrderStatusId).ToSelectList())
                    <input type="submit" name="btnSaveOrderStatus" value="@T("Admin.Common.Save")" id="btnSaveOrderStatus" class="adminButton" onclick="return confirm('@T("Admin.Common.AreYouSure")');"  />
                    <input type="submit" name="btnCancelOrderStatus" value="@T("Admin.Common.Cancel")" onclick="toggleChangeOrderStatus(false);return false;" id="btnCancelOrderStatus" class="adminButton" />
                </div>
            </td>
        </tr>
    }
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Id):
        </td>
        <td class="adminData">
            @Model.Id
        </td>
    </tr>
    @if (!Model.IsLoggedInAsVendor)
    {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderGuid):
            </td>
            <td class="adminData">
                @Model.OrderGuid
            </td>
        </tr>
    }
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.StoreName):
        </td>
        <td class="adminData">
            @Model.StoreName
        </td>
    </tr>
    <tr class="adminSeparator">
        <td colspan="2">
            <hr />
        </td>
    </tr>

    @if (!Model.IsLoggedInAsVendor)
    {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerId):
            </td>
            <td class="adminData">
                @Html.ActionLink(Model.CustomerInfo, "Edit", "Customer", new { id = Model.CustomerId }, new { })
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerIp):
            </td>
            <td class="adminData">
                @Model.CustomerIp
            </td>
        </tr>
        if (Model.RecurringPaymentId > 0)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.RecurringPaymentId):
            </td>
            <td class="adminData">
                <a href="@Url.Action("Edit", "RecurringPayment", new { id = Model.RecurringPaymentId })">@T("Admin.Common.View")</a>
            </td>
        </tr>
        }
        if (!String.IsNullOrEmpty(Model.VatNumber))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.VatNumber):
            </td>
            <td class="adminData">
                @Model.VatNumber
            </td>
        </tr>
        }
        if (Model.AffiliateId.HasValue && Model.AffiliateId.Value > 0)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AffiliateId):
            </td>
            <td class="adminData">
                <a href="@Url.Action("Edit", "Affiliate", new { id = Model.AffiliateId.Value })">@Model.AffiliateId.Value - @T("Admin.Common.View")</a>
            </td>
        </tr>
        }
        if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderSubtotalInclTax):
            </td>
            <td class="adminData">
                @Model.OrderSubtotalInclTax
            </td>
        </tr>
        }
        if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderSubtotalExclTax):
            </td>
            <td class="adminData">
                @Model.OrderSubtotalExclTax
            </td>
        </tr>
        }
        if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
            && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountInclTax))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderSubTotalDiscountInclTax):
            </td>
            <td class="adminData">
                @Model.OrderSubTotalDiscountInclTax
            </td>
        </tr>
        }
        if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
            && !String.IsNullOrEmpty(Model.OrderSubTotalDiscountExclTax))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderSubTotalDiscountExclTax):
            </td>
            <td class="adminData">
                @Model.OrderSubTotalDiscountExclTax
            </td>
        </tr>
        }
        if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderShippingInclTax):
            </td>
            <td class="adminData">
                @Model.OrderShippingInclTax
            </td>
        </tr>
        }
        if (Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderShippingExclTax):
            </td>
            <td class="adminData">
                @Model.OrderShippingExclTax
            </td>
        </tr>
        }
        if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.IncludingTax)
            && !String.IsNullOrEmpty(Model.PaymentMethodAdditionalFeeInclTax))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.PaymentMethodAdditionalFeeInclTax):
            </td>
            <td class="adminData">
                @Model.PaymentMethodAdditionalFeeInclTax
            </td>
        </tr>
        }
        if ((Model.AllowCustomersToSelectTaxDisplayType || Model.TaxDisplayType == TaxDisplayType.ExcludingTax)
            && !String.IsNullOrEmpty(Model.PaymentMethodAdditionalFeeExclTax))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.PaymentMethodAdditionalFeeExclTax):
            </td>
            <td class="adminData">
                @Model.PaymentMethodAdditionalFeeExclTax
            </td>
        </tr>
        }
        if (Model.DisplayTaxRates)
        {
            foreach (var tr in Model.TaxRates)
            {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Tax) @tr.Rate%:
            </td>
            <td class="adminData">
                @tr.Value
            </td>
        </tr>
            }
        }
        if (Model.DisplayTax)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Tax):
            </td>
            <td class="adminData">
                @Model.Tax
            </td>
        </tr>
        }
        if (!String.IsNullOrEmpty(Model.OrderTotalDiscount))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderTotalDiscount):
            </td>
            <td class="adminData">
                @Model.OrderTotalDiscount
            </td>
        </tr>
        }
        foreach (var gc in Model.GiftCards)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.GiftCards[0].CouponCode) (@(gc.CouponCode)):
            </td>
            <td class="adminData">
                @gc.Amount
            </td>
        </tr>
        }
        if (Model.RedeemedRewardPoints > 0)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.RedeemedRewardPoints):
            </td>
            <td class="adminData">
                @Model.RedeemedRewardPoints @T("Admin.Orders.Fields.RedeemedRewardPoints.Points")
                <text>/</text>
                @Model.RedeemedRewardPointsAmount
            </td>
        </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.OrderTotal):
            </td>
            <td class="adminData">
                @Model.OrderTotal
            </td>
        </tr>
        if (!String.IsNullOrEmpty(Model.RefundedAmount))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.RefundedAmount):
            </td>
            <td class="adminData">
                @Model.RefundedAmount
            </td>
        </tr>
        }
        if (Model.UsedDiscounts.Count > 0)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.UsedDiscounts):
            </td>
            <td class="adminData">
                @for (int i = 0; i < Model.UsedDiscounts.Count; i++)
                {
                    var discount = Model.UsedDiscounts[i];
                    <a href="@Url.Action("Edit", "Discount", new { id = discount.DiscountId })">@discount.DiscountName</a>
                    if (i != Model.UsedDiscounts.Count - 1)
                    {
                        <text>,</text>
                    }
                }
            </td>
        </tr>
        }
        <tr id="trEditOrderTotals">
            <td colspan="2">
                <table style="border: solid 1px black; padding: 5px;">
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.OrderSubtotalInclTaxValue):
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.InclTax") @Html.EditorFor(model => model.OrderSubtotalInclTaxValue)
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.ExclTax") @Html.EditorFor(model => model.OrderSubtotalExclTaxValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.OrderSubTotalDiscountInclTaxValue):
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.InclTax") @Html.EditorFor(model => model.OrderSubTotalDiscountInclTaxValue)
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.ExclTax") @Html.EditorFor(model => model.OrderSubTotalDiscountExclTaxValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.OrderShippingInclTaxValue):
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.InclTax") @Html.EditorFor(model => model.OrderShippingInclTaxValue)
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.ExclTax") @Html.EditorFor(model => model.OrderShippingExclTaxValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.PaymentMethodAdditionalFeeInclTaxValue):
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.InclTax") @Html.EditorFor(model => model.PaymentMethodAdditionalFeeInclTaxValue)
                        </td>
                        <td>
                            @T("Admin.Orders.Fields.Edit.ExclTax") @Html.EditorFor(model => model.PaymentMethodAdditionalFeeExclTaxValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.TaxRatesValue):
                        </td>
                        <td colspan="2">
                            @Html.EditorFor(model => model.TaxRatesValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.TaxValue):
                        </td>
                        <td colspan="2">
                            @Html.EditorFor(model => model.TaxValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.OrderTotalDiscountValue):
                        </td>
                        <td colspan="2">
                            @Html.EditorFor(model => model.OrderTotalDiscountValue)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.NopLabelFor(model => model.OrderTotalValue):
                        </td>
                        <td colspan="2">
                            @Html.EditorFor(model => model.OrderTotalValue)
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" name="btnEditOrderTotals" value="@T("Admin.Orders.Fields.EditOrderTotals")" onclick=" toggleOrderTotals(true);return false; " id="btnEditOrderTotals" class="adminButton" />
                <input type="submit" name="btnSaveOrderTotals" value="@T("Admin.Orders.Fields.SaveOrderTotals")" id="btnSaveOrderTotals" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
            </td>
            <td>
                <input type="submit" name="btnCancelOrderTotals" value="@T("Admin.Orders.Fields.CancelOrderTotals")" onclick=" toggleOrderTotals(false);return false; " id="btnCancelOrderTotals" class="adminButton" />
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardType):
            </td>
            <td class="adminData">
                <span id="lblCardType">@Model.CardType</span>
                @Html.EditorFor(model => model.CardType)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardName):
            </td>
            <td class="adminData">
                <span id="lblCardName">@Model.CardName</span>
                @Html.EditorFor(model => model.CardName)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber || !String.IsNullOrEmpty(Model.CardNumber))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardNumber):
            </td>
            <td class="adminData">
                <span id="lblCardNumber">@Model.CardNumber</span>
                @Html.EditorFor(model => model.CardNumber)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardCvv2):
            </td>
            <td class="adminData">
                <span id="lblCardCvv2">@Model.CardCvv2</span>
                @Html.EditorFor(model => model.CardCvv2)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardExpirationMonth):
            </td>
            <td class="adminData">
                <span id="lblCardExpirationMonth">@Model.CardExpirationMonth</span>
                @Html.EditorFor(model => model.CardExpirationMonth)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CardExpirationYear):
            </td>
            <td class="adminData">
                <span id="lblCardExpirationYear">@Model.CardExpirationYear</span>
                @Html.EditorFor(model => model.CardExpirationYear)
            </td>
        </tr>
        }
        if (Model.AllowStoringCreditCardNumber)
        {
        <tr>
            <td>
                <input type="submit" name="btnEditCC" value="@T("Admin.Orders.Fields.EditCC")" onclick=" toggleCC(true);return false; " id="btnEditCC" class="adminButton" />
                <input type="submit" name="btnSaveCC" value="@T("Admin.Orders.Fields.SaveCC")" id="btnSaveCC" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
            </td>
            <td>
                <input type="submit" name="btnCancelCC" value="@T("Admin.Orders.Fields.CancelCC")" onclick=" toggleCC(false);return false; " id="btnCancelCC" class="adminButton" />
            </td>
        </tr>
        }
        if (Model.DisplayPurchaseOrderNumber)
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.PurchaseOrderNumber):
            </td>
            <td class="adminData">
                @Model.PurchaseOrderNumber
            </td>
        </tr>
        }
        if (!String.IsNullOrEmpty(Model.AuthorizationTransactionId))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AuthorizationTransactionId):
            </td>
            <td class="adminData">
                @Model.AuthorizationTransactionId
            </td>
        </tr>
        }
        if (!String.IsNullOrEmpty(Model.CaptureTransactionId))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CaptureTransactionId):
            </td>
            <td class="adminData">
                @Model.CaptureTransactionId
            </td>
        </tr>
        }
        if (!String.IsNullOrEmpty(Model.SubscriptionTransactionId))
        {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.SubscriptionTransactionId):
            </td>
            <td class="adminData">
                @Model.SubscriptionTransactionId
            </td>
        </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.PaymentMethod):
            </td>
            <td class="adminData">
                @Model.PaymentMethod
            </td>
        </tr>
    }
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.PaymentStatus):
        </td>
        <td class="adminData">
            @Model.PaymentStatus &nbsp;
                
    @if (!Model.IsLoggedInAsVendor)
    {
        if (Model.CanCapture)
        {
        <input type="submit" name="captureorder" value="@T("Admin.Orders.Fields.Capture")" id="captureorder" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
        if (Model.CanMarkOrderAsPaid)
        {
        <input type="submit" name="markorderaspaid" value="@T("Admin.Orders.Fields.MarkAsPaid")" id="markorderaspaid" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
        if (Model.CanRefund)
        {
        <input type="submit" name="refundorder" value="@T("Admin.Orders.Fields.Refund")" id="refundorder" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
        if (Model.CanRefundOffline)
        {
        <input type="submit" name="refundorderoffline" value="@T("Admin.Orders.Fields.RefundOffline")" id="refundorderoffline" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
        if (Model.CanPartiallyRefund)
        {
        <input type="submit" id="partiallyrefundorder" name="partiallyrefundorder" value="@T("Admin.Orders.Fields.PartialRefund")" onclick=" javascript:OpenWindow('@(Url.Action("PartiallyRefundOrderPopup", "Order", new { id = Model.Id, online = true, btnId = "btnRefreshPage", formId = "order-form" }))', 500, 300, true); return false; " class="adminButton" />
        <text>&nbsp;</text>
        }
        if (Model.CanPartiallyRefundOffline)
        {
        <input type="submit" id="partiallyrefundorderoffline" name="partiallyrefundorderoffline" value="@T("Admin.Orders.Fields.PartialRefundOffline")" onclick=" javascript:OpenWindow('@(Url.Action("PartiallyRefundOrderPopup", "Order", new { id = Model.Id, online = false, btnId = "btnRefreshPage", formId = "order-form" }))', 500, 300, true); return false; " class="adminButton" />
        <text>&nbsp;</text>
        }
        if (Model.CanVoid)
        {
        <input type="submit" name="voidorder" value="@T("Admin.Orders.Fields.Void")" id="voidorder" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
        if (Model.CanVoidOffline)
        {
        <input type="submit" name="voidorderoffline" value="@T("Admin.Orders.Fields.VoidOffline")" id="voidorderoffline" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
        <text>&nbsp;</text>
        }
    }
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.CreatedOn):
        </td>
        <td class="adminData">
            @Html.DisplayFor(model => model.CreatedOn)
        </td>
    </tr>
</table>
